//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Validation Application Block
//===============================================================================
// Code file original author: Martin Lapierre, http://devinstinct.com
//===============================================================================

using System;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using EntLibContrib.Validation.Validators;

namespace EntLibContrib.Validation.Configuration
{
	/// <summary>
	/// Configuration object to describe an instance of class <see cref="CollectionCountValidator"/>.
	/// </summary>
	/// <remarks>
	/// Spin-off of the StringLengthValidatorData class.
	/// </remarks>
	/// <seealso cref="CollectionCountValidator"/>
	/// <seealso cref="ValidatorData"/>
	public class CollectionCountValidatorData : RangeValidatorData<int>
	{
		#region Construction
		/// <summary>
		/// <para>Initializes a new instance of the <see cref="CollectionCountValidatorData"/> class.</para>
		/// </summary>
		public CollectionCountValidatorData()
		{ }

		/// <summary>
		/// <para>Initializes a new instance of the <see cref="CollectionCountValidatorData"/> class with a name.</para>
		/// </summary>
		/// <param name="name">The name for the instance.</param>
		public CollectionCountValidatorData(string name)
			: base(name, typeof(CollectionCountValidator))
		{ }
		#endregion

		#region Protected Methods
		/// <summary>
		/// Creates the <see cref="CollectionCountValidator"/> described by the configuration object.
		/// </summary>
		/// <param name="targetType">The type of object that will be validated by the validator.</param>
		/// <returns>The created <see cref="CollectionCountValidator"/>.</returns>
		protected override Validator DoCreateValidator(Type targetType)
		{
			return new CollectionCountValidator(this.LowerBound,
					this.LowerBoundType,
					this.UpperBound,
					this.UpperBoundType,
					Negated);
		}
		#endregion
	}
}